package cn.edu.sasu.controller;

import cn.edu.sasu.common.base.LayuiRespResult;
import cn.edu.sasu.common.base.RespResult;
import cn.edu.sasu.common.constants.Constant;
import cn.edu.sasu.domain.dto.SysDeptDTO;
import cn.edu.sasu.domain.dto.SysDoctorDTO;
import cn.edu.sasu.domain.entity.SysDoctor;
import cn.edu.sasu.domain.entity.UpDept;
import cn.edu.sasu.domain.vo.SysDeptVO;
import cn.edu.sasu.service.SysDeptService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 2024/4/27
 *
 * @author ganxue
 */
@RestController
@RequestMapping("/dept")
public class SysDeptController {
    @Resource
    private SysDeptService sysDeptService;

    @GetMapping("/findSysDoctorAll")
    public LayuiRespResult findDoctorAll(Integer page, Integer limit,Integer hospitalId) {
        return sysDeptService.deptList(page, limit,hospitalId);
    }

    @GetMapping("/findSysDepts")
    public RespResult Depts(Integer hospitalId) {
        List<SysDeptVO> deptList = sysDeptService.getDepts(Constant.DELETE_FLAG_YES,hospitalId);
        return RespResult.success(deptList);
    }
    @GetMapping("/findSysDepotsList")
    public RespResult DeptsL() {
        List<UpDept> deptList = sysDeptService.getDeptsList(Constant.DELETE_FLAG_YES);
        return RespResult.success(deptList);
    }

    // 搜索
    @GetMapping("/search")
    public LayuiRespResult search(Integer page, Integer limit, String doctorName) {
        return sysDeptService.search(page, limit, doctorName);
    }

    // 保存
    @PostMapping("/save")
    public RespResult save(@RequestBody @Validated SysDeptDTO sysDeptDTO) {
        return sysDeptService.saves(sysDeptDTO);
    }
    @PostMapping("/updates")
    public RespResult updates(@RequestBody @Validated SysDeptDTO sysDeptDTO) {
        return sysDeptService.updates(sysDeptDTO);
    }
}

